Login Script for PostGreSQL and PHP not working =[

Posted by MrEnder on Stack Overflow See other posts from Stack Overflow or by MrEnder
Published on 2010-03-24T03:28:39Z Indexed on 2010/03/24 3:33 UTC
Read the original article Hit count: 396

Filed under:
|
|
|
|

Ok I'm quite new at logins what not so bare with me here lol but I gota learn so don't discourage me.

I tried this so far

<?php

$error = "";

$conn = pg_connect("host=localhost dbname=brittains_db user=brittains password=XXXX" );

$sql = "SELECT * FROM logins";
$result = pg_query($conn, $sql);




if($_SERVER["REQUEST_METHOD"] == "GET") {

    $userName="";
    $password="";

}

else if($_SERVER["REQUEST_METHOD"] == "POST") {

    $userName=trim($_POST["userNameLogin"]);
    $password=trim($_POST["passwordLogin"]);

    if(pg_fetch_result($results, $userName, "userName")==true && pg_fetch_result($results, $password, "userName")==true) {

        setcookie("userIDforDV", $userName, time()+43200);

    }
    else {

        $error = "Your username and or password is incorrect";

    }

}

$userName = $_COOKIE['userIDforDV'];

if(isset($userName) && $userName!="") {

    echo "Welcome " . $userName;

}

echo $error;

?>

<form>
    <table>
        <tr>
            <td class="signupTd">
                User Name:&nbsp;
            </td>
            <td>
                <input type="text" name="userNameLogin" value="" size="20" />
            </td>
        </tr>
        <tr>
            <td class="signupTd">
                Password:&nbsp;
            </td>
            <td>
                <input type="password" name="passwordLogin" value="" size="20" />
            </td>
        </tr>
        <tr>
            <td class="signupTd" colspan="2">
                <input type="submit" name="submit" value="Submit"/>
            </td>
        </tr>
    </table>
</form>

that was the idea I came up with... but its prolly a really bad idea and it doesn't work... how might I go about this properly? I need really detailed descriptions please.

Thanks a tun Shelby

© Stack Overflow or respective owner

Related posts about login

Related posts about cookie